//
//  FixFrames.m
//  ImageAnimation
//
//  Created by apple on 8/26/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "FixFrame.h"

@implementation FixFrame
@synthesize fixFrameValue;
@synthesize horizontalIndex;
@synthesize verticalIndex;
@synthesize draggableView;
- (id)initWithHorizontal:(int)_horizontalIndex andVertical:(int)_verticalIndex
{
    self = [super init];
    if (self) {
        // Initialization code here.
        horizontalIndex = _horizontalIndex;
        verticalIndex = _verticalIndex;
    }
    
    return self;
}

- (FixFrame *)getFixFrameByMovingDirection:(MovingDirection)movingDirection{

    int horizontal = self.horizontalIndex;
    int vertical = self.verticalIndex;
    CGRect rect = self.fixFrameValue;
    switch (movingDirection) {
        case MovingDirectionTop:
            vertical--;
            rect.origin.y = rect.origin.y - rect.size.height;
            break;
        case MovingDirectionBottom:
            vertical++;
            rect.origin.y = rect.origin.y + rect.size.height;
            break;
        case MovingDirectionLeft:
            horizontal--;
            rect.origin.x = rect.origin.x - rect.size.width;
            break;
        case MovingDirectionRight:
            horizontal++;
            rect.origin.x = rect.origin.x + rect.size.width;
            break;
        default:
            break;
    }
    
    FixFrame *result = [[FixFrame alloc] initWithHorizontal:horizontal andVertical:vertical];
    result.fixFrameValue = rect;
    return result;
}
@end
